// 
// Decompiled by Procyon v0.5.36
// 

package com.akamai.botman;

import android.util.*;
import android.os.*;
import java.util.*;

public final class ah
{
    public static android.util.Pair<java.lang.String, java.lang.Long> a(final float[] array, final float n) {
        java.lang.String concat = "";
        long n2 = 0L;
        java.lang.String string = "Incorrect sensor data";
        try {
            final float[] array2 = new float[array.length];
            java.lang.System.arraycopy(array, 0, array2, 0, array.length);
            new java.lang.StringBuilder("Input for Simple Quantization encoding: ").append(com.akamai.botman.ak.a(array));
            final java.lang.Throwable[] array3 = new java.lang.Throwable[0];
            final android.util.Pair<java.lang.Float, java.lang.Float> a;
            final float floatValue = (float)(a = a(array)).first;
            final float floatValue2 = (float)a.second;
            new java.lang.StringBuilder("min and max of SimpQuant data: min(").append(floatValue).append("), max(").append(floatValue2).append(")");
            final java.lang.Throwable[] array4 = new java.lang.Throwable[0];
            final java.lang.String a2 = com.akamai.botman.ak.a(array, floatValue, floatValue2);
            final java.lang.Throwable[] array5 = new java.lang.Throwable[0];
            final java.lang.String a3 = com.akamai.botman.aj.a(a2);
            final java.lang.Throwable[] array6 = new java.lang.Throwable[0];
            final int length = a3.length();
            final java.lang.Throwable[] array7 = new java.lang.Throwable[0];
            final long a4 = com.akamai.botman.ag.a(a3);
            final java.lang.Throwable[] array8 = new java.lang.Throwable[0];
            final float a5 = a(floatValue);
            final float a6 = a(floatValue2);
            final java.lang.String format = java.lang.String.format(java.util.Locale.US, "2;%.2f;%.2f;%d;%s", a5, a6, a4, a3);
            final java.lang.Throwable[] array9 = new java.lang.Throwable[0];
            final long n3 = java.lang.Math.round(a5 * 100.0f + a6 * 100.0f) + a4;
            final java.lang.Throwable[] array10 = new java.lang.Throwable[0];
            final com.akamai.botman.am am;
            final int intValue = (int)(am = new com.akamai.botman.am(format, length, n3)).b;
            final float[] array11 = array2;
            new java.lang.StringBuilder("Input for DCT encoding: ").append(com.akamai.botman.ak.a(array11));
            final java.lang.Throwable[] array12 = new java.lang.Throwable[0];
            final float[] array13 = array11;
            if (android.os.Build$VERSION.SDK_INT >= 19) {
                java.util.Objects.<float[]>requireNonNull(array13);
            }
            final int length2;
            if (java.lang.Integer.bitCount(length2 = array13.length) != 1) {
                throw new java.lang.IllegalArgumentException("Length must be power of 2");
            }
            final float[] array14 = array13;
            final int n4 = 0;
            final int n5 = length2;
            com.akamai.botman.ai.a(array14, n4, n5, new float[n5]);
            new java.lang.StringBuilder("Fast DCT Encoded: ").append(com.akamai.botman.ak.a(array11));
            final java.lang.Throwable[] array15 = new java.lang.Throwable[0];
            new java.lang.StringBuilder("Shrinked DCT (").append(n).append(")<").append(com.akamai.botman.ak.a(array11, n)).append(">: ").append(com.akamai.botman.ak.a(array11));
            final java.lang.Throwable[] array16 = new java.lang.Throwable[0];
            final float n6 = array11[0];
            final float[] array17 = new float[array11.length - 1];
            java.lang.System.arraycopy(array11, 1, array17, 0, array11.length - 1);
            final android.util.Pair<java.lang.Float, java.lang.Float> a7;
            final float floatValue3 = (float)(a7 = a(array17)).first;
            final float floatValue4 = (float)a7.second;
            new java.lang.StringBuilder("Coef, min and max of DCT data: Coef(").append(n6).append("), min(").append(floatValue3).append("), max(").append(floatValue4).append(")");
            final java.lang.Throwable[] array18 = new java.lang.Throwable[0];
            final java.lang.String a8 = com.akamai.botman.ak.a(array17, floatValue3, floatValue4);
            final java.lang.Throwable[] array19 = new java.lang.Throwable[0];
            final java.lang.String a9 = com.akamai.botman.aj.a(a8);
            final java.lang.Throwable[] array20 = new java.lang.Throwable[0];
            final int length3 = a9.length();
            final java.lang.Throwable[] array21 = new java.lang.Throwable[0];
            final long a10 = com.akamai.botman.ag.a(a9);
            final java.lang.Throwable[] array22 = new java.lang.Throwable[0];
            final float a11 = a(floatValue3);
            final float a12 = a(floatValue4);
            final float a13 = a(n6);
            final java.lang.String format2 = java.lang.String.format(java.util.Locale.US, "1;%.2f;%.2f;%.2f;%d;%s", a11, a12, a13, a10, a9);
            final java.lang.Throwable[] array23 = new java.lang.Throwable[0];
            final long n7 = java.lang.Math.round(a11 * 100.0f + a12 * 100.0f + a13 * 100.0f) + a10;
            final java.lang.Throwable[] array24 = new java.lang.Throwable[0];
            final com.akamai.botman.am am2;
            final int intValue2 = (int)(am2 = new com.akamai.botman.am(format2, length3, n7)).b;
            final java.lang.Throwable[] array25 = new java.lang.Throwable[0];
            final java.lang.Throwable[] array26 = new java.lang.Throwable[0];
            if (intValue - intValue2 < 20) {
                final java.lang.Throwable[] array27 = new java.lang.Throwable[0];
                concat = (java.lang.String)am.a;
                n2 = (long)am.c;
            }
            else {
                final java.lang.Throwable[] array28 = new java.lang.Throwable[0];
                concat = (java.lang.String)am2.a;
                n2 = (long)am2.c;
            }
        }
        catch (java.lang.Exception ex) {
            final java.lang.String message = ex.getMessage();
            com.akamai.botman.al.c("DctEncoding", "Failed in DCT processing: ".concat(java.lang.String.valueOf(message)), new java.lang.Throwable[0]);
            string = string + ": " + message;
        }
        if (concat.isEmpty()) {
            com.akamai.botman.al.c("DctEncoding", string, new java.lang.Throwable[0]);
            concat = "0;".concat(java.lang.String.valueOf(string));
            n2 = 0L;
        }
        final java.lang.Throwable[] array29 = new java.lang.Throwable[0];
        final java.lang.Throwable[] array30 = new java.lang.Throwable[0];
        return (android.util.Pair<java.lang.String, java.lang.Long>)new android.util.Pair((java.lang.Object)concat, (java.lang.Object)n2);
    }
    
    private static float a(final float n) {
        return java.lang.Math.round(n * 100.0f) / 100.0f;
    }
    
    private static android.util.Pair<java.lang.Float, java.lang.Float> a(final float[] array) {
        float n = array[0];
        float n2 = array[0];
        for (int length = array.length, i = 0; i < length; ++i) {
            final float n3;
            if ((n3 = array[i]) < n) {
                n = n3;
            }
            else if (n3 > n2) {
                n2 = n3;
            }
        }
        return (android.util.Pair<java.lang.Float, java.lang.Float>)new android.util.Pair((java.lang.Object)n, (java.lang.Object)n2);
    }
}
